package com.anycc.cloud.core.controller;

import com.anycc.cloud.core.dto.EchartsDataDto;
import com.anycc.cloud.core.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * index Controller
 */
@RestController
@RequestMapping("index")
public class IndexController {
    @Autowired
    private IndexService indexService;

    /**
     * 获取首页信息
     *
     * @return Map<String, List<EchartsDataDto>>
     */
    @GetMapping("indexInfo")
    public Map<String, List<EchartsDataDto>> getIndexInfo() {
        Map<String, List<EchartsDataDto>> infoMap = new HashMap<>();
        infoMap.put("entityCount", indexService.getEntityAccountList());
        infoMap.put("accountUserRatio", indexService.getAccountUserRatio());
        infoMap.put("instanceAmount", indexService.getEurekaInstancesAmount());
        return infoMap;
    }
}
